<?php

namespace app\model;
use think\model\relation\BelongsTo;

/**
 * @mixin \think\Model
 */
class AdminMerchantNet extends Base
{
    //
    protected $autoWriteTimestamp = true;

    const PAY_TYPE = [0 => '通联支付'];
    const MERCHANT_TYPE = [0 => '水电充值'];

    public function getPayTypeTextAttr($value, $data)
    {
        $type = self::PAY_TYPE;
        return $type[$data['pay_type']] ?? '';
    }

    public function getMerchantTypeTextAttr($value, $data)
    {
        $type = self::MERCHANT_TYPE;
        return $type[$data['merchant_type']] ?? '';
    }

    public function school(): BelongsTo {
        return $this->belongsTo(AdminSchool::class, 'school_id')->bind([
            'school_name' => 'name'
        ]);
    }

}
